<template>
	<div>
		<div class="page-content padding-top">
			<div class="slidebar">
				<span v-for="(item,index) of genderOptions" :class="{on:index==gender}" @click="genderChange(index)">
					<i class="ion-checkmark-circled"></i>
					{{item.shopName}}
				</span>
			</div>
		</div>
	</div>
</template>

<script>
	import { bus } from 'bus.js'
	export default{
		data:function(){
			return {
				//shopId 当前状态
				gender:0,
				genderOptions:[],
				shopId:''				
			}
		},
		methods:{
			genderChange(e){
				this.gender = e
				this.shopId = this.genderOptions[e].shopId
//				console.log(this.shopId)
				bus.$emit('slidebarChange',this.shopId)
			},			
			shopIdGet(){
				window.axios.get(baseUrl+'/controller/getShopList',{
					params:{
						marketId:this.userSession.marketId,
						shopId:this.userSession.shopId,
						shopState:1
					}
				}).then((res)=>{
					this.genderOptions=res.data.result
					for(var i = 0;i<this.genderOptions.length;i++){
						if(this.genderOptions[i].shopId == this.shopId)
							this.gender = i
					}
				})
			}
		},
		mounted:function(){
		},
		computed: {
			// 获取缓存数据
			userSession() {
				return sess.get('userSession')
			}
		},
		created: function(){
			bus.$on('shopIdChanges',(val)=>{
				this.shopId = val
				this.shopIdGet()
			})
		}
	}
</script>
